#include <bits/stdc++.h>
using namespace std;

int main() {
    //parse input 
    int people_num;
    cin >> people_num;
    vector<int> time(people_num);

    sort(time.begin(), time.end());
    if (time.size() == 1) {
        cout << time[0];
    } else if (time.size() == 2) {
        cout << time[1];
    }
    // 定义状态dp[i]表示i个人过河所需的最少时间
    int state1 = time[0];
    int state2 = time[1];
    int tmp1, tmp2;
    int cur_state;
    priority_queue<int, vector<int>, greater<int>> already_cross;
    already_cross.push(state2);
    already_cross.push(state1);
    for (int i = 2 ; i < time.size(); ++i) {
        // tmp1 = state2 + already_cross.top() + 
        // cur_state = min(state2+)
    }
}